package com.itheima.dao;

import com.itheima.domain.Course;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CourseDao {

    @Results({

            @Result(column = "id",property = "id",id = true),
            @Result(column = "name",property = "name"),

            @Result(
                    property = "studentList",
                    javaType = List.class,
                    column = "id",
                    many = @Many(select = "com.itheima.dao.StudentDao.findById")
            )
    })
    @Select("select * from course")
    public List<Course> findAll();
}
